import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';

class ThemeService extends GetxService {
  // 存储键
  static const THEME_KEY = 'isDarkMode';
  
  // GetStorage实例
  final _box = GetStorage();
  
  // 是否是暗黑模式
  bool get isDarkMode => _box.read(THEME_KEY) ?? false;
  
  // 设置主题模式
  ThemeMode get themeMode => isDarkMode ? ThemeMode.dark : ThemeMode.light;
  
  // 主题切换
  void switchTheme() {
    // 保存相反的模式
    _box.write(THEME_KEY, !isDarkMode);
    
    // 应用新主题
    Get.changeThemeMode(isDarkMode ? ThemeMode.dark : ThemeMode.light);
  }
} 